<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>User List</title>
</head>
<body>
    姓名：
    <input type="text" id="userName" value=""><br>
    年龄:
    <input type="text" id="userAge" value=""><br>
    工号:
    <input type="text" id="userCard" value=""><br>
    <input type="button" value="确认" onclick="addUser()" />
</body>

<script type="text/javascript" th:src="@{/static/js/jquery-2.1.4.min.js}"></script>
<script th:inline="javascript">
    function addUser() {
        var userName = $('#userName').val();
        var userAge = $('#userAge').val();
        var userCard = $('#userCard').val();
        $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url: '/front/user/addUser',
            data: {
                'userName': userName,
                'userAge': userAge,
                'userCard': userCard
            },
            success: function (result) {
                alert(JSON.stringify(result));
            }
        });
    }
</script>
</html>